---
title: "SQL-001: Insert a legal letter request"
summary: Insert a new legal letter request via stored procedure and return the generated request number.
status: draft
owner: SAIF Documentation Pipeline
last_reviewed: 2026-08-21
library: SAIF.Application.Claim.Legal
reference_type: embedded
---

# SQL-001 Insert a legal letter request

Stored procedure call that creates a new letter-request row for a legal case (e.g., a Defense Evaluation Form or recon-request letter) and returns the generated request sequence number. Executed by `LegalManagerBase.insertLetterRequest`, which is called from the Print DEF letter and recon-request letter flows.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-001 |
| **Operation type** | Create |
| **Execution method** | Stored procedure (`IDataRequest` via `DPI.DataAccessLayer.ProcessPortalRequest`) |
| **Database** | Oracle |
| **Command type** | StoredProcedure |
| **Business object** | N/A (Application layer) |
| **Criteria property** | N/A (Application layer) |
| **Lifecycle method** | N/A (Application layer) |
| **Application class** | `LegalManagerBase` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `letterTypeCode` | Input | String | 5 | Letter-type code (e.g., `DEFLT`) identifying which letter template to request. |
| `aLegalCaseNum` | Input | Decimal | N/A | Legal case sequence number the letter request is associated with. |
| `holdDate` | Input | Date (nullable) | N/A | Requested hold/mail date; sent as `DbType.Date` (NULL) when the caller passes `Date.MinValue`, otherwise the actual date value. |
| `createUser` | Input | String | 30 | User ID recorded as the creator of the letter request. |
| `aClaimId` | Input | Decimal | N/A | Claim ID the letter request is associated with. |
| `requestNum` | InputOutput | Long/Decimal | N/A | Generated letter-request sequence number, returned by the procedure and read back via `PortalRequest.DataRequest(0).ParmValue("requestNum")`. |

## Tables

No tables are directly referenced by this application-layer call; all data access occurs inside the Oracle package body `pk80001_LEGALNET.insertLetterRequest`, which was not retrieved for this run**.

## Sample SQL

```sql
-- Stored procedure call (procedure body resides in the Oracle database)
pk80001_LEGALNET.insertLetterRequest(
  :letterTypeCode,
  :aLegalCaseNum,
  :holdDate,
  :createUser,
  :aClaimId,
  :requestNum)
```

Bind names reflect the `AddParm()` names used in `LegalManagerBase.insertLetterRequest`; `requestNum` is bound `ParameterDirection.InputOutput`. The procedure body resides in the Oracle database and was not retrieved for this run (see [Procedures](../procedures/index.md)).

## Operations and processes
- [Insert letter request](../operations/insert-letter-request.md)
- [Print DEF letter](../operations/print-def-letter.md)
- [Save hearing request / update case](../operations/save-hearing-request-update-case.md)

## Business rules
- [BR-LGL-004: Printing a DEF letter marks the case DEF-sent](../business-rules.md#br-lgl-004-printing-a-def-letter-marks-the-case-def-sent)*

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Sources
- `SAIF.Application.Claim.Legal\LegalManagerBase.vb`
